package com.atguigu.lease.web.admin.service.impl;

import com.atguigu.lease.model.entity.LabelInfo;
import com.atguigu.lease.web.admin.mapper.LabelInfoMapper;
import com.atguigu.lease.web.admin.mapper.RoomLabelMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.lease.model.entity.RoomLabel;
import com.atguigu.lease.web.admin.service.RoomLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author liubo
* @description 针对表【room_label(房间&标签关联表)】的数据库操作Service实现
* @createDate 2023-07-24 15:48:00
*/
@Service
public class RoomLabelServiceImpl extends ServiceImpl<RoomLabelMapper, RoomLabel>
    implements RoomLabelService{
@Autowired
private LabelInfoMapper labelInfoMapper;
    @Override
    public List<LabelInfo> selectListByRoomId(Long id) {
        List<RoomLabel> list = super.list(new LambdaQueryWrapper<RoomLabel>().eq(RoomLabel::getRoomId, id));
        List<LabelInfo> labelInfos = labelInfoMapper.selectList(new LambdaQueryWrapper<LabelInfo>().in(LabelInfo::getId, list.stream().map(RoomLabel::getLabelId).toList()));
        return labelInfos;
    }
}




